package ex3;

import java.util.*;

public class Warehouse implements CountWeight {
	
	public final double MAXWEIGHT = 2000;
    private List<Merchandise> merchandises;
	

	public Warehouse() {
		merchandises = new ArrayList<Merchandise>();
		

	}

	public List<Merchandise> getMerchandises() {
		return merchandises;
	}

	public void setMerchandises(List<Merchandise> merchandises) {
		this.merchandises = merchandises;
	}

	public void addMerchandise(Merchandise m) {
		if (!isFull()) {
			
			merchandises.add(m);
		}
		
		if (isFull()) {
			System.out.println("Full warehouse");
			merchandises.remove(m);
		}
		
		
		
	}

	public boolean isFull() {
		
		return this.count() >= MAXWEIGHT;
	}

	public void removeMerchandise(Merchandise m) {
		merchandises.remove(m);
	}

	public double count() {
		double sum = 0;
		for (int i = 0; i < merchandises.size(); i++) {
			sum += merchandises.get(i).getWeight();
		}

		return sum;
	}

}
